VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsPerformanceMonitor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Collection" ,"Performance"
Attribute VB_Ext_KEY = "Member0" ,"Performance"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit

'local variable to hold collection
Private mCol As Collection

Public Function Add(PerfName As String, PerfStartTime As Long, PerfEndTime As Long, PerfTotalTime As Long, sKey As String) As Performance
    'create a new object
    Dim objNewMember As Performance
    Set objNewMember = New Performance


    'set the properties passed into the method
    objNewMember.PerfName = PerfName
    objNewMember.PerfStartTime = PerfStartTime
    objNewMember.PerfEndTime = PerfEndTime
    objNewMember.PerfTotalTime = PerfTotalTime
    mCol.Add objNewMember, sKey


    'return the object created
    Set Add = objNewMember
    Set objNewMember = Nothing


End Function

Public Function NewEnum() As IUnknown
    Set NewEnum = mCol.[_NewEnum]
End Function

Public Function List() As String
    Dim max As Long, i As Long, s As String, l As String
    If Timings = False Then
        List = "Timings are currently off."
        Exit Function
    End If
    max = mCol.Count
    For i = 1 To 40
        l = l & "-"
    Next i
    s = "   " & l & vbCrLf & "Timings as of " & Time & vbCrLf & l & vbCrLf
    For i = 1 To max
        s = s & Left$(Perf(i).PerfName & "                                        ", 40) & vbTab & Format("0.000", Perf(i).PerfTotalTime / 1000) & vbTab & Perf(i).PerfHitCount & vbTab & Format(((Perf(i).PerfTotalTime / Perf(i).PerfHitCount) / 1000), "0.000") & vbCrLf
    Next i
    List = s
End Function

Public Property Get Item(vntIndexKey As Variant) As Performance
Attribute Item.VB_UserMemId = 0
  Set Item = mCol(vntIndexKey)
End Property

Public Property Get Count() As Long
    Count = mCol.Count
End Property

Public Sub Remove(vntIndexKey As Variant)
    mCol.Remove vntIndexKey
End Sub

Private Sub Class_Initialize()
    Set mCol = New Collection
End Sub

Private Sub Class_Terminate()
    Set mCol = Nothing
End Sub

